package com.xindz.cn.mvptest.components.main.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.xindz.cn.mvptest.R;
import com.xindz.cn.mvptest.components.main.data.StartBean;

import java.util.List;

/**
 * @name LeanCloudTwo
 * @class name：com.xindz.cn.leancloudtwo.fragment
 * @class describe
 * @anthor XINDZ
 * @time 2017/10/24 11:17
 * @change
 * @chang time
 * @class describe
 */
public class FragListAdapter extends BaseAdapter {

    private Context context;
    private List<StartBean> list;

    public FragListAdapter(List<StartBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolde holde;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_frag_main, null);
            holde = new ViewHolde();
            holde.tv = convertView.findViewById(R.id.tv_item_frag_main);
            convertView.setTag(holde);
        }
        holde = (ViewHolde) convertView.getTag();

        holde.tv.setText(list.get(position).title);

        return convertView;
    }

    static class ViewHolde {
        TextView tv;
    }
}
